<?php

use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;

class CreateSystemUserTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
     /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('system_user', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '' ,'id' => 'user_id' ,'primary_key' => ['user_id']]);
        $table->addColumn('user_guid', 'string', ['limit' => 36,'null' => true,'signed' => true,'comment' => '用户guid',])
            ->addColumn('user_name', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '用户名称',])
            ->addColumn('user_code', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '用户登录名',])
            ->addColumn('user_pwd', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '用户密码',])
            ->addColumn('user_phone', 'string', ['limit' => 11,'null' => true,'signed' => true,'comment' => '用户手机',])
            ->addColumn('user_type', 'enum', ['values' => ['1','2','3','4']])
            ->addColumn('sex', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '性别',])
            ->addColumn('create_time', 'timestamp', ['null' => true,'signed' => true,'comment' => '创建时间',])
            ->addColumn('register_ip', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '创建ip',])
            ->addColumn('land_time', 'datetime', ['null' => true,'signed' => true,'comment' => '登录时间',])
            ->addColumn('land_ip', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '登录ip',])
            ->addColumn('land_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '登录状态',])
            ->addColumn('is_admin', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '管理员',])
            ->addColumn('is_enable', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '是否启用',])
            ->addColumn('is_csd', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '是否客服',])
            ->addColumn('csd_sign', 'string', ['limit' => 500,'null' => true,'signed' => true,'comment' => '客服签名',])
            ->addColumn('only_no', 'string', ['limit' => 300,'null' => true,'signed' => true,'comment' => '登录唯一标识',])
            ->addColumn('org_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '组织id',])
            ->addColumn('api_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '第三方id',])
            ->addIndex(['user_id'], ['name' => 'user_id'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('system_user');
    }
    
}
